package com.viethp.mt.objects;

import java.util.ArrayList;
import java.util.Vector;

import org.ksoap2.serialization.SoapObject;

import android.util.Log;

public class GetApplicantListResponse {
	private static final String ERROR_CODE = "ErrorCode";
	private static final String APPLICANT_LIST_ARRAY = "ApplicantArray";
	private static final String TOTAL_PAGE = "TotalPage";
	private static final String PAGE = "PageNumber";
	private ErrorCode errorCode;
	private int totalPage, page;
	private ArrayList<OApplicant> OitemArray;

	public GetApplicantListResponse(SoapObject result) {
		if (result != null && result.hasProperty(ERROR_CODE)) {
			this.errorCode = new ErrorCode(
					(SoapObject) result.getProperty(ERROR_CODE));
		} else {
			this.errorCode = null;
			OitemArray = new ArrayList<OApplicant>();
			if (result != null && result.hasProperty(APPLICANT_LIST_ARRAY)) {
				@SuppressWarnings("unchecked")
				Vector<SoapObject> soapArray = (Vector<SoapObject>) result
						.getProperty(APPLICANT_LIST_ARRAY);
				if (soapArray != null) {
					for (SoapObject soapObject : soapArray) {
						OitemArray.add(new OApplicant(soapObject));
					}
				}
			} else
				OitemArray = null;
			Log.d("total", result.getProperty(TOTAL_PAGE).toString() + "test");
			if (result.hasProperty(TOTAL_PAGE)) {
				totalPage = Integer.parseInt(result.getProperty(TOTAL_PAGE)
						.toString());

			} else
				totalPage = 0;

			if (result.hasProperty(PAGE)) {
				page = Integer.parseInt(result.getProperty(PAGE).toString());

			} else
				page = 0;

		}
	}

	public ErrorCode getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(ErrorCode errorCode) {
		this.errorCode = errorCode;
	}

	public ArrayList<OApplicant> getApplicantArray() {
		return OitemArray;
	}

	public void setApplicantArray(ArrayList<OApplicant> OitemArray) {
		this.OitemArray = OitemArray;
	}

	public void setTotalPage(int totalpage) {
		this.totalPage = totalpage;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getTotalPage() {
		return this.totalPage;
	}

	public int getPage() {
		return this.page;
	}

}
